package com.neuronrobotics.replicator.gui.preview.android;

import java.util.Arrays;

import com.neuronrobotics.opengl.scene.GLHandles;
import com.neuronrobotics.opengl.scene.SimpleMutableLineNode;
import com.neuronrobotics.opengl.scene.TransformGroupNode;

public class PositionIndicatorGroup extends TransformGroupNode{

	private SimpleMutableLineNode xIndicator, zIndicator;
	
	private float[] centerPoint;
	
	public PositionIndicatorGroup(GLHandles handles,float[] center, float x, float z){
		super();
		this.centerPoint = Arrays.copyOf(center, 3);
		
		float[] xCoords = new float[6];
		xCoords[0] = center[0];
		xCoords[1] = center[1];
		xCoords[2] = center[2];
		
		xCoords[3] = x;
		xCoords[4] = center[1];
		xCoords[5] = center[2];
		xIndicator = new SimpleMutableLineNode(handles, xCoords);		
		
		float[] zCoords = new float[6];
		zCoords[0] = center[0];
		zCoords[1] = center[1];
		zCoords[2] = center[2];
		
		zCoords[3] = center[0];
		zCoords[4] = center[1];
		zCoords[5] = z;
		
		zIndicator = new SimpleMutableLineNode(handles, zCoords);	
		
		xIndicator.setColor(.8f, .8f, 1.0f, 1.0f);
		zIndicator.setColor(1f, .8f, .8f, 1.0f);
		
		xIndicator.setLightsOn(false);
		zIndicator.setLightsOn(false);
		
		this.addChild(xIndicator);
		this.addChild(zIndicator);
		
	}
	
	public void setX(float x){
		xIndicator.setPointB(x, centerPoint[1], centerPoint[2]);
	}
	
	public void setZ(float z){
		zIndicator.setPointB(centerPoint[0], centerPoint[1], z);
	}
}
